﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AsociarObjetoAFormulario.aspx.cs" Inherits="AsociarObjetoAFormulario" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../../css/estilos.css" rel="stylesheet" />
    <link href="../../css/colorbox/colorbox.css" rel="stylesheet" />
    <script type="text/javascript" src="../../js/jquery-1.9.0.min.js"></script>
    <script type="text/javascript" src="../../js/colorbox/jquery.colorbox.js"></script>
    <script type="text/javascript" src="../../js/GEN_js.js"></script>
    <title></title>

    <script type="text/javascript">
        function Validar() {
            if (ValidarCheck() < 1) {
                $('#<%=chkObjeto.ClientID%>').removeClass("rbl-campos-oblig-sb").addClass("rbl-campos-oblig-cb");
                 $("#dvAlerta2").html('Debe seleccionar al menos un Perfil');
                 $("#dvAlerta2").css("display", "block");
                 $("#fijo").css("height", "50px");
                 return false;
             } else {
                 $('#chkObjeto').removeClass("rbl-campos-oblig-sb").addClass("rbl-campos-oblig-cb");
                 $("#colorbox, #cboxOverlay").appendTo('form:first');
                 AbrirModal('330', '210', true, false, '#yesno', false);
                 $('#yesno').css("display", "block");
                 return false;
             }
         }

         function ValidarCheck() {
             document.getElementById("<%=chkObjeto.ClientID%>").childElementCount > 0;
             var CHK = document.getElementById("<%=chkObjeto.ClientID%>");
             var checkbox = CHK.getElementsByTagName("input");
             var counter = 0;
             for (var i = 0; i < checkbox.length; i++) {
                 if (checkbox[i].checked) {
                     counter++;
                 }
             }
             return counter;
         }

    </script>
</head>
<body>
    <form id="frmFormularioObjeto" runat="server">
        <asp:HiddenField runat="server" ID="hdfFormulario" />
        <div class="titulo-modal">Asociar Objeto a Formulario</div>
        <br />
        <div class="div-box-gris">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="txt-campos-int">Formulario</td>
                    <td>
                        <asp:DropDownList runat="server" ID="ddlFormulario" class="field_element"></asp:DropDownList>
                    </td>
                    <td>
                        <asp:Button ID="btnBuscar" runat="server" Text="Buscar" CssClass="skip" OnClick="btnBuscar_Click" /></td>
                </tr>
            </table>
        </div>
        <br />
        <table width="99%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td>
                    <div id="Layer1" class="div-scroll" style="overflow: auto">
                        <asp:CheckBoxList ID="chkObjeto" runat="server"></asp:CheckBoxList>
                    </div>
                </td>
            </tr>
            <tr align="center">
                <td colspan="2">
                    <br />
                    <asp:Button ID="btnGrabar" runat="server" CssClass="skip" Text="Grabar" OnClientClick="return Validar()" />
                    <input id="btnCancelar" type="button" class="skip" onclick="window.parent.CerrarModal();" value="Cancelar" />
            </tr>
        </table>

        <div id="fijo" runat="server">
            <div class="alertaRegistro alerta" runat="server" style="display: none;" id="dvAlerta2">
            </div>
        </div>

        <div id="yesno" style="display: none">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="titulo-modal">Mensaje del Sistema</td>
                </tr>
            </table>
            <br />
            <table width="100%" align="center" border="0" cellspacing="2" cellpadding="1">
                <tr>
                    <td align="center" width="72">
                        <img alt="Interrogación" src="../../images/icon-interrogacion-modal.png" /></td>
                    <td class="" align="center" style="padding-left: 6px; padding-right: 6px;">¿Esta seguro que desea guardar los cambios?</td>
                </tr>
            </table>
            <table width="80%" border="0" align="center" cellspacing="0" cellpadding="0">
                <tr>
                    <td align="center">
                        <asp:Button ID="btnSi" runat="server" CssClass="skip" Text="Si" OnClick="btnSi_Click" />
                        <input id="btnNo" type="button" class="skip" onclick="window.parent.CerrarModal();" value="No" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
